package testng.service;

import java.util.ArrayList;
import java.util.List;

import com.iwhalecloud.citybrain.flow.platform.manager.FlowEngineApplication;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.FlowUser;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.app.FlowAppAuthorizeVo;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.app.FlowAppQueryVo;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.model.app.FlowAppUpdateVo;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.repository.FlowAppRepository;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;

/**
 * @author cheng.huaxing
 * @date 2019-03-04
 */
@SpringBootTest(classes = FlowEngineApplication.class)
public class FlowAppServiceImplTest extends AbstractTransactionalTestNGSpringContextTests {

    @Autowired
    private FlowAppRepository flowAppRepository;

    //@Test
    public void testQuery() {
        FlowAppQueryVo appQueryVo = new FlowAppQueryVo();
        appQueryVo.setAppId(10);
        flowAppRepository.list(appQueryVo);
    }

    //@Test
    public void testAuthorize() {
        FlowAppAuthorizeVo appAuthorizeVo = new FlowAppAuthorizeVo();
        appAuthorizeVo.setAppIds(new ArrayList<>());
        appAuthorizeVo.getAppIds().add(14);
        appAuthorizeVo.setTenantId(1);
        //flowAppRepository.authorize(appAuthorizeVo);
    }

    //@Test
    public void testAuthorize2() {
        FlowAppAuthorizeVo appAuthorizeVo = new FlowAppAuthorizeVo();
        appAuthorizeVo.setAppIds(new ArrayList<>());
        appAuthorizeVo.getAppIds().add(14);
        //flowAppRepository.authorize(appAuthorizeVo);
    }

    //@Test
    public void testAuthorizeUser() {
        List<FlowUser> userInfoList = new ArrayList<>();
        FlowUser userInfo = new FlowUser();
        userInfo.setId(6);
        userInfo.setUserCode("13580447986");
        userInfoList.add(userInfo);
        flowAppRepository.authorize(70, userInfoList);
    }

    //@Test
    public void testUpdate() {
        FlowAppUpdateVo appUpdateVo = new FlowAppUpdateVo();
        appUpdateVo.setId(1);
        appUpdateVo.setAppCode("yingyong003");
        flowAppRepository.update(appUpdateVo);
    }
}